{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Shuffle Arrays in Unison"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A function for NumPy arrays in unison."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> from mlxtend.preprocessing import shuffle_arrays_unison"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 - Scaling a Pandas DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "X:\n",
      "[[1 2 3]\n",
      " [4 5 6]\n",
      " [7 8 9]]\n",
      "y:\n",
      "[1 2 3]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from mlxtend.preprocessing import shuffle_arrays_unison\n",
    "X = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
    "y = np.array([1, 2, 3])\n",
    "print('X:\\n%s' % X)\n",
    "print('y:\\n%s' % y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "X2:\n",
      "[[4 5 6]\n",
      " [1 2 3]\n",
      " [7 8 9]]\n",
      "y2:\n",
      "[2 1 3]\n"
     ]
    }
   ],
   "source": [
    "X2, y2 = shuffle_arrays_unison(arrays=[X, y], random_seed=3)\n",
    "print('X2:\\n%s' % X2)\n",
    "print('y2:\\n%s' % y2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## API"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "## shuffle_arrays_unison\n",
      "\n",
      "*shuffle_arrays_unison(arrays, random_seed=None)*\n",
      "\n",
      "Shuffle NumPy arrays in unison.\n",
      "\n",
      "**Parameters**\n",
      "\n",
      "- `arrays` : array-like, shape = [n_arrays]\n",
      "\n",
      "    A list of NumPy arrays.\n",
      "\n",
      "- `random_seed` : int (default: None)\n",
      "\n",
      "    Sets the random state.\n",
      "\n",
      "**Returns**\n",
      "\n",
      "- `shuffled_arrays` : A list of NumPy arrays after shuffling.\n",
      "\n",
      "\n",
      "**Examples**\n",
      "\n",
      "    >>> import numpy as np\n",
      "    >>> from mlxtend.preprocessing import shuffle_arrays_unison\n",
      "    >>> X1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n",
      "    >>> y1 = np.array([1, 2, 3])\n",
      "    >>> X2, y2 = shuffle_arrays_unison(arrays=[X1, y1], random_seed=3)\n",
      "    >>> assert(X2.all() == np.array([[4, 5, 6], [1, 2, 3], [7, 8, 9]]).all())\n",
      "    >>> assert(y2.all() == np.array([2, 1, 3]).all())\n",
      "    >>>\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "with open('../../api_modules/mlxtend.preprocessing/shuffle_arrays_unison.md', 'r') as f:\n",
    "    print(f.read())"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
